// 工具库
import { message } from 'antd';

export function alertMsg(messageText, type, duration = 1000) {
  if (duration === 1000) {
    if (type === 'error') duration = 3000;
    else if (type === 'warning') duration = 2000;
  }
  
  message[type]({
    content: messageText,
    duration: duration / 1000, // antd的duration是以秒为单位
  });
}

// 暴露函数
const tools = {
  alertMsg,
};

export default tools;